# -*- coding: utf-8 -*-

import xadmin
from xadmin import views
from .models import Category, Tag, Article


class BaseSetting(object):
    enable_themes = True
    use_bootswatch = True


class GlobalSetting(object):
    site_title = u'博客管理'
    site_footer = u'快活の小道士'
    # global_search_models = [Article, Category]
    global_models_icon = {
        Article: 'fa fa-book',
        Tag: 'fa fa-tags',
        Category: 'fa fa-file',
    }  # 设置models的全局图标
    # 设置主题可选择
    enable_themes = True
    use_bootswatch = True
    # 设置菜单风格
    menu_style = "accordion"
    # 设置各模块菜单标题
    apps_label_title = {
        'auth': u'权限管理',
        'myblog': u'博客管理',
    }


class CategoryAdmin(object):
    list_display = ('name',)


class TagAdmin(object):
    list_display = ('name',)


class ArticleAdmin(object):
    list_display = ('title', 'created_time', 'modified_time', 'category', 'author')
    show_detail_fields = ['category', 'author']


xadmin.site.register(views.BaseAdminView, BaseSetting)
xadmin.site.register(views.CommAdminView, GlobalSetting)
xadmin.site.register(Category, CategoryAdmin)
xadmin.site.register(Tag, TagAdmin)
xadmin.site.register(Article, ArticleAdmin)
